package com.lightMS.agenda.db;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
	
	
    public DatabaseHelper(Context context) {
		super(context, DatabaseConstants.DATABASE_NAME, null, DatabaseConstants.DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " + DatabaseConstants.EVENT_TABLE + " (" + 
						DatabaseConstants.EVENT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
						DatabaseConstants.EVENT_NAME + " TEXT" +
					");");
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		android.util.Log.w(DatabaseConstants.EVENT_TABLE,
				"Upgrading database from " + oldVersion + " to " + newVersion);
		db.execSQL("DROP TABLE IF EXISTS " + DatabaseConstants.EVENT_TABLE);
		onCreate(db);
	}
}
